﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using System.Web;
using Jumbot.Common;
using Jumbot.DataOper;

namespace JumbotCms.DataObject
{
    /// <summary>
    /// HTML模板方案表信息
    /// </summary>
    public class TemplateProject
    {
        private string m_Id = "0";
        private string m_Title = string.Empty;
        private string m_Dir = string.Empty;
        private int m_IsDefault;
        private string m_Info;

        public string Id
        {
            get { return m_Id; }
            set { m_Id = value; }
        }
        /// <summary>
        /// HTML模板方案名称
        /// </summary>
        public string Title
        {
            set { m_Title = value; }
            get { return m_Title; }
        }
        /// <summary>
        /// HTML模板方案路径
        /// </summary>
        public string Dir
        {
            set { m_Dir = value; }
            get { return m_Dir; }
        }
        public string Info
        {
            set { m_Info = value; }
            get { return m_Info; }
        }
        public int IsDefault
        {
            get { return m_IsDefault; }
            set { m_IsDefault = value; }
        }

        public TemplateProject()
        {
        }
        public void GetAllColumn(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT * FROM [jcms_normal_templateproject] WHERE id=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                Id = _id;
                Title = dr["Title"].ToString();
                Dir = dr["Dir"].ToString();
                Info = dr["Info"].ToString();
                IsDefault = Validator.StrToInt(dr["IsDefault"].ToString(), 0);
            }
        }
        public string GetTitle(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [Title] FROM [jcms_normal_templateproject] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["Title"].ToString();
            }
            return string.Empty;
        }
        public string GetDir(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [Dir] FROM [jcms_normal_templateproject] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["Dir"].ToString();
            }
            return string.Empty;
        }
        public string GetInfo(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [Info] FROM [jcms_normal_templateproject] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["Info"].ToString();
            }
            return string.Empty;
        }
        public int GetIsDefault(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [IsDefault] FROM [jcms_normal_templateproject] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return Validator.StrToInt(dt.Rows[0]["IsDefault"].ToString(), 0);
            }
            return 0;
        }
    }
}
